<?php
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
global $wpdb;
$user_ID = get_current_user_id();
$_status = get_user_meta($user_ID, 'client_status');
// check user have the images of the FIRST choosing images 
$exist_choose_1 = $wpdb->get_row("SELECT * FROM gallery_selected_img WHERE user_id = {$user_ID} AND type = 1");

if (isset($_POST['imgid']) && !count($exist_choose_1)) {

    $selected_imgid = $_POST['imgid'];
    $wpdb->insert('gallery_selected_img', array('user_id' => $user_ID, 'image_id' => serialize($selected_imgid), 'type' => 1, 'status' => 0));
    exit;
}
get_header();


// get top menu of anh cuoi pages 
get_sidebar('anhcuoi');

$thumb_path = my_get_home_path() . "/media/user_{$user_ID}/chon-hinh/";


if (is_dir($thumb_path)) { //IF USER HAVE NOT CHOOOSE IMG 
    $allthumbs = scandir($thumb_path);
} else {

    echo " <h1> <center>Folder is not exists </center></h1> ";
    die;
}
?>
<div id="sv-container"></div>
<div class="anhcuoiblock">
    <!-- Add fancyBox -->
    <link rel="stylesheet" href="<?php echo bloginfo('template_url'); ?>/js/fancybox/jquery.fancybox.css?v=2.1.5" type="text/css" media="screen" />
    <script type="text/javascript" src="<?php echo bloginfo('template_url'); ?>/js/fancybox/jquery.fancybox.pack.js?v=2.1.5"></script>
    <!-- Optionally add helpers - button, thumbnail and/or media -->
    <link rel="stylesheet" href="<?php echo bloginfo('template_url'); ?>/js/fancybox/helpers/jquery.fancybox-buttons.css?v=1.0.5" type="text/css" media="screen" />
    <script type="text/javascript" src="<?php echo bloginfo('template_url'); ?>/js/fancybox/helpers/jquery.fancybox-buttons.js?v=1.0.5"></script>
    <script type="text/javascript" src="<?php echo bloginfo('template_url'); ?>/js/svcore/js/simpleviewer.js"></script>
    <?php
	
$xml_path = 	my_get_home_path() . "/media/user_{$user_ID}/hinh-goc/orignal/";
$xml_url  =   	get_site_url() . "/media/user_{$user_ID}/hinh-goc/orignal/";

if (!file_exists($xml_path . "/gallery.xml") || 1) {
    $fileLocation = $xml_path . "/gallery.xml";
        $file = fopen($fileLocation, "w");
        $content = '<?xml version="1.0" encoding="UTF-8"?>

                    <simpleviewergallery
                        
                        galleryStyle="MODERN"
                        textColor="FFFFFF"
                        frameColor="FFFFFF"
                        frameWidth="20"
                        thumbPosition="BOTTOM"
                        thumbColumns="10"
                        thumbRows="1"
                        showNavButtons="TRUE" 
                        showAutoPlayButton="TRUE" 
                        showOpenButton="FASLE" 
                        showFullscreenButton="FASLE" 
                        maxImageWidth="2000"
                        maxImageHeight="1640"
                        useFlickr="false"
                        flickrUserName=""
                        flickrTags=""
                        languageCode="AUTO"
                        languageList=""     
                        imagePath=""
                        thumbPath=""
                        
                    >';
        if (is_array($allthumbs)) {
            foreach ($allthumbs as $key => $row) {
                if ($key == 0 || $key == 1)
                    continue;

                $content .= '<image imageURL="' . $row . '" thumbURL="' . $row . '" linkURL="" linkTarget="" >
                                <caption></caption> 
                            </image>';
            }
        }
        $content .= '</simpleviewergallery>';
        fwrite($file, $content);
        fclose($file);
    }
    ?>

    <div class="list-album">
    <div class="input-hidden"></div>
    <div class="share-select">
        <div class="container text-right">
            <?php if ($_status[0] != 'finish') { ?>
                <div class="ibtn select-btn">Chọn hình cưới</div>
                <div class="ibtn cancel-btn" style="display:none;">Hủy</div>
            <?php } ?>
            <div class="ibtn share-btn">Chia sẻ</div>
            <div class="ibtn slide-btn"><span class="glyphicon glyphicon-play"></span> Slideshow</div> 
            <?php if ($_status[0] != 'finish') { ?>
                <div class="actions-inner actions-font1 actions-color1 actions-center" style="display:none;">
                    <span class="actions-item actions-select">Chọn:&nbsp;<a href="javascript:;" class="actions-select-link actions-all"> Tất cả</a>&nbsp;|&nbsp;<a href="javascript:;" class="actions-select-link actions-none">Bỏ chọn</a>&nbsp;|&nbsp; Tổng số hình bạn chọn: <span id="totalimg" class="xcolor xbold">0</span> tấm</span>
                    <span class="actions-text"><a href="">Quy định chọn hình lần 1</a></span>
                </div>
                <div class="actions-inner note_numimg xcolor xbold actions-color1" style="display:none;" > Bạn chỉ đượ chọn 40 - 45 tấm hình vào album, đừng chọn vượt số lượng quy định </div>
            <?php } ?>
        </div>

        <div id="ctl03_ControlBox_SharePopup" class="share-popup popup popup-bgcolor1 popup-border1 popup-color1 popup-font1" style="top: 30%; left: 30%; visibility: inherit;display:none;z-index:9999;">
            <div id="ctl03_ControlBox_SharePopup_ShareFrame" class="share-frame share-bgcolor0 share-color0 share-font0">
                <div class="sf-section-bg share-border0 share-bgcolor4">
                    <div class="sf-section-perm" id="ctl03_ControlBox_SharePopup_ShareFrame-links">
                        <div class="sf-head share-bgcolor5 share-color5">
                            <h4>Link to Gallery</h4>
                        </div>
                        <div class="sf-body">
                            <div id="ctl03_ControlBox_SharePopup_ShareFrame_Links" class="sf-links">
                                <div id="ctl03_ControlBox_SharePopup_ShareFrame_Links-url-item" class="sfl-url">
                                    <label for="ctl03_ControlBox_SharePopup_ShareFrame_Links-url">Copy and paste the link to this <span>gallery</span>:</label>
                                    <div class="sfl-box">
                                        <input value="<?php echo site_url() ?>/chon-hinh" type="text" id="ctl03_ControlBox_SharePopup_ShareFrame_Links-url" readonly="readonly">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="sf-section-e sf-section-perm" id="ctl03_ControlBox_SharePopup_ShareFrame-share">
                        <div class="sf-head share-bgcolor6 share-color6">
                            <h4>Share via...</h4>
                        </div>
                        <div class="sf-body" style="display: block;">
                            <div id="ctl03_ControlBox_SharePopup_ShareFrame_Share" class="sf-share">
                                <div class="sfs-container sfsc-4">
                                    <a data="http://www.facebook.com/share.php?u=<?php echo site_url() ?>/chon-hinh" class="sfs-facebook">
                                        <div class="sfs-icon sfs-facebook-icon"></div>
                                        <span class="share-font10">
                                            Facebook
                                        </span>
                                    </a>
                                    <a data="https://twitter.com/share?via=<?php echo site_url() ?>/chon-hinh&text=Link to Gallery" class="sfs-twitter">
                                        <div class="sfs-icon sfs-twitter-icon"></div>
                                        <span class="share-font10">
                                            Twitter
                                        </span>
                                    </a>
                                    <a data="https://plusone.google.com/_/+1/confirm?hl=en&url=<?php echo site_url() ?>/chon-hinh" class="sfs-gplus">
                                        <div class="sfs-icon sfs-gplus-icon"></div>
                                        <span class="share-font10">
                                            Google+
                                        </span>
                                    </a>
                                    <a data="mailto:?subject=Invitation to view photographs&body=Link to Gallery: <?php echo site_url() ?>/chon-hinh" class="sfs-email">
                                        <div class="sfs-icon sfs-email-icon"></div>
                                        <span class="share-font10">
                                            Email
                                        </span>
                                    </a>
                                    <div class="clear"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="popup-footer">
                <div class="button">
                    <div class="standard button-color1 button-bgcolor1 button-border1" id="ctl03_ControlBox_SharePopup_ctl00-state">
                        <div class="middle">
                            <div class="button-font1">
                                Close
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <script type="text/javascript">
            var svAPI; //svAPI is the object to call API methods on
            $(window).resize(function(){
                $('.container .col-7.abcxyz').css('width',($('.container').outerWidth(true)-315-10)+'px');
            });
            $(document).keyup(function(e) {
                if (e.keyCode == 27) {
                    $('#sv-container').html('');
                    $('#sv-container').attr('style', '');
                    $('html').attr('style', '');
                    $('body').attr('style', '');
                    $('.header').show();
                    $('.anhcuoi.menu').show();
                    $('.breadcrumbs').show();
                    $('#wpadminbar').show();
                    $('#flash').parent().hide();
                    $('.container .col-7.abcxyz').css('width',($('.container').outerWidth(true)-315-10)+'px');
                }
            });
            $('#flash').keyup(function(e) {
                if (e.keyCode == 27) {
                    $('#sv-container').html('');
                    $('#sv-container').attr('style', '');
                    $('html').attr('style', '');
                    $('body').attr('style', '');
                    $('.header').show();
                    $('.anhcuoi.menu').show();
                    $('.breadcrumbs').show();
                    $('#wpadminbar').show();
                    $('#flash').parent().hide();
                    $('.container .col-7.abcxyz').css('width',($('.container').outerWidth(true)-315-10)+'px');
                }
            });
            $('.popup-footer .button-font1').live('click', function() {
                $('#ctl03_ControlBox_SharePopup').slideUp();
                $('.mask-black').fadeOut();
            });
            $("#ctl03_ControlBox_SharePopup_ShareFrame_Links-url").click(function() {
                $(this).select();
            });
            $('.share-btn').live('click', function() {
                $('.mask-black').fadeIn();
                $('#ctl03_ControlBox_SharePopup').slideDown();
            });
            $('.sfs-container.sfsc-4 a').click(function() {
                window.open($(this).attr('data'), 't', 'toolbar=0,resizable=1,status=0,width=640,height=528');
                return false;
            });
            $('.slide-btn').live('click', function() {
                $('#ctl03_ControlBox_SharePopup').slideUp();
                var flashvars = {};
                flashvars.enableAPI = "true";
                flashvars.baseURL = "<?php echo $xml_url ?>";

                var params = {};
                params.allowfullscreen = true;
                params.allowscriptaccess = "always";
                params.bgcolor = "222222";
                params.wmode = "opaque";

                var attributes = {};
                attributes.id = "svInstance";
                attributes.name = "svInstance";

                $('html').attr('style', 'width:100%;height:100%;');
                $('body').attr('style', 'width:100%;height:100%;');

                simpleviewer.ready(function() {
                    svAPI = simpleviewer.load("sv-container", "100%", "100%", "222222", true, flashvars, params, attributes);
                    $('.header').hide();
                    $('.anhcuoi.menu').hide();
                    $('.breadcrumbs').hide();
                    var element = document.body;
                    var requestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullScreen;
                    if (requestMethod) { // Native full screen.
                        requestMethod.call(element);
                    } else if (typeof window.ActiveXObject !== "undefined") { // Older IE.
                        var wscript = new ActiveXObject("WScript.Shell");
                        if (wscript !== null) {
                            wscript.SendKeys("{F11}");
                        }
                    }
                });
            });

            // fancy box confirm 

            function fancyConfirm_cancel() {
                
                jQuery.fancybox.close();
            }
            function fancyConfirm_ok() {
                save_add_image();
                jQuery.fancybox.close();
            }
            function fancyConfirm() {
                msg = "<h1 style='width: 400px;'> Quy định chọn hình </h1><ul><li>Bạn có chắc chọn đúng số hình làm album ? </li><li>Bạn đã chọn hình lớn chưa ? </li><li> Nếu chọn <span> Đồng ý</span> bạn sẽ không được chọn lại </li></ul>"; 
                jQuery.fancybox({
                    modal: true,
                    content: "<div class=\"confirm_area\">" + msg + "<div class=\"bt_area\"><input onclick=\"fancyConfirm_cancel()\" class=\"bt_cancel\" type=\"button\" value=\"Chọn tiếp\"><input onclick=\"fancyConfirm_ok()\" class=\"bt_ok\" type=\"button\" value=\"Đồng ý\"></div></div>"
                });
            }

            

            //end fancybox confirm 
            $('.select-btn').live('click', function() {
                $('.slide_thumb').css('display', '');
                $('.slide_detail').css('display', 'none');
                document.location.hash = '';
                $('#ctl03_ControlBox_SharePopup').slideUp();
                if (!$(this).hasClass('active')) {
                    $(this).addClass('active');
                    $(this).html('Lưu hình chọn');

                    bind_add_thumb();
                } else {
                    fancyConfirm(); 
                   
                }
            });
            $('.cancel-btn').live('click', function() {
                $('.select-btn').removeClass('active');
                $('.select-btn').html('Chọn hình');

                bind_select_thumb();
            });
            $('.actions-all').live('click', function() {
                $('.thumbs li').each(function() {
                    var items = $('.thumbs li');
                    for (var i = 0; i < items.length; i++) {
                        if (!$(items[i]).hasClass('checked')) {
                            $(items[i]).find('img').click();

                        }
                    }
                });
            });
            $('.actions-none').live('click', function() {
                var items = $('.thumbs li');
                for (var i = 0; i < items.length; i++) {
                    if ($(items[i]).hasClass('checked')) {
                        $(items[i]).find('img').click();
                    }
                }
            });
            $('.slide_thumb.select_mode .thumbs li .glyphicon-zoom-in').live('click', function() {
                $(this).next().click();
            });

            function save_add_image() {
                var selected_image = $('.slide_thumb.select_mode .thumbs li.checked');
                for (var i = 0; i < selected_image.length; i++) {
                    $('<input type="hidden" name="imgid[]" value="' + $(selected_image[i]).find('.imgid').attr('itemid') + '" />').appendTo('.input-hidden');
                }
                $.ajax({
                    url: '<?php echo site_url() ?>/chon-hinh',
                    type: 'post',
                    data: $('.input-hidden input[type=hidden]'),
                    dataType: 'text',
                    beforeSend: function() {
                        $('#messagebox').css('display', 'block');
                    },
                    complete: function() {
                        $('#messagebox').css('display', 'none');
                        $('.input-hidden').html('');
                    },
                    success: function(theDateReturned) {
                        $('.select-btn').removeClass('active');
                        $('.select-btn').html('Select Photos');
                        bind_select_thumb();
                        document.location.href = '<?php echo home_url('chon-hinh-lan-1') ?>';
                    },
                    error: function(xhr, ajaxOptions, thrownError) {
                        $('#messagebox').css('display', 'none');
                        $('.input-hidden').html('');
                    }
                });
            }
            // check total checked image
            function check_total_img() {
                var total = $('.checked').length;
                if (total <= 45) {
                    $('#totalimg').html(total);
                } else {
                    alert("Bạn đã chọn đủ số hình cần cho album ảnh");
                    return false;
                }
                return true;
            }
            function bind_add_thumb() {
                $('.share-btn').css('display', 'none');
                $('.slide-btn').css('display', 'none');
                $('.cancel-btn').css('display', '');
                $('.actions-inner').css('display', '');
                $('.slide_thumb').addClass('select_mode');
                $('.imgid + img').unbind('click').bind('click', function() {
                    if (!$(this).parent().hasClass('checked') && $('.checked').length < 45) {

                        $(this).parent().addClass('checked');
					   $(this).parent().children().last().css('display','block');
                        check_total_img();

                    } else {
                        $(this).parent().removeClass('checked');
                        $(this).parent().children().last().hide();
                        check_total_img();
                    }
                });
            }

            function bind_select_thumb() {
                $('.actions-none').click();
                $('.share-btn').css('display', '');
                $('.slide-btn').css('display', '');
                $('.cancel-btn').css('display', 'none');
                $('.actions-inner').css('display', 'none');
                $('.slide_thumb').removeClass('select_mode');
                $('.imgid + img').unbind('click').bind('click', function() {
                    imgid = $(this).prev().html();
                    document.location.hash = imgid;
                    init_gallery_random();
                });
            }
        </script>
    </div>
    <style type="text/css">
        .list-album{
            margin: 15px;
        }
        .anhcuoiblock .container {
            max-width: 1400px !important;
            width: 100%;
        }
        .thumbs.chl1 li{
            width: 9%;
            margin: 0.5%;
        }
        .thumbs.chl1 li img{
            width: 100%;
        }
        .share-select > div{
            padding: 0 8px;
        }
    </style>
    <div class="main slide_thumb">
        <div class="container anhcuoi">
            <ul class="thumbs chl1">
                <?php
                if (is_array($allthumbs)) {
                    foreach ($allthumbs as $key => $row) {
                        if ($key == 0 || $key == 1)
                            continue;
                        $thumburl = get_site_url() . "/media/user_{$user_ID}/chon-hinh/" . $row;
                        $mediumurl = get_site_url() . "/media/user_{$user_ID}/hinh-goc/orignal/" . $row;
                        $imgid = $key - 1;
                        ?>
                        <li>
                            <span class="imgid" itemid="<?php echo $row ?>" ><?php echo $imgid ?></span>
													
                            <img src="<?php echo $thumburl ?>" title="<?php echo $row ?>" alt="<?php echo $row ?>" />
                            <span class="glyphicon glyphicon-zoom-in"></span>
                            <a class="fancybox_thumb" href="<?php echo $mediumurl ?>"></a>
								<span class="filename" style="display:none"><?php echo $row ?></span>
                        </li>
                        <?php
                    }
                }
                ?>
            </ul>
        </div>
    </div>
    </div>
    <!-- SLIDE DETAIL -->
    <script src="<?php echo bloginfo('template_url'); ?>/js/bootstrap-paginator.js"></script>
    <script src="<?php echo bloginfo('template_url'); ?>/js/qunit-1.11.0.js"></script>
    <div class="main slide_detail" style="display:none;">
        <div class="container">
            <div class="col-7 no-left abcxyz showimage">
                <?php
                if (is_array($allthumbs)) {
                    foreach ($allthumbs as $key => $row) {
                        if ($key == 0 || $key == 1)
                            continue;
						$thumburl = get_site_url() . "/media/user_{$user_ID}/hinh-goc/full" . $row;
                        $imgid = $key - 1;
                        ?>
                        <div class="fullimage"><img src="<?php echo $thumburl ?>" title="<?php echo $row ?>" alt="<?php echo $row ?>" /></div>
                        <?php
                        break;
                    }
                }
                ?>
            </div>
            <div class="col-5 abcxyz">
                <div class="control">
                    <div class="col-2 next-last no-left"><span class="glyphicon glyphicon-chevron-left"></span></div>
                    <div class="col-8 info-paginattion">
                        <span class="current-image">1</span> of <span class="total-image"><?php echo (count($allthumbs) - 2); ?></span> photos
                    </div>
                    <div class="col-2 next-last no-right"><span class="glyphicon glyphicon-chevron-right"></span></div>
                    <div class="col-12 no-left no-right">
                        <div class="thumbimage">
                            <?php
                            if (is_array($allthumbs)) {
                                foreach ($allthumbs as $key => $row) {
                                    if ($key == 0 || $key == 1)
                                        continue;
                                   
									 $thumburl = get_site_url() . "/media/user_{$user_ID}/hinh-goc/tiny/" . $row;
									 $mediumurl = get_site_url() . "/media/user_{$user_ID}/hinh-goc/orignal/" . $row;
									 
                                    $imgid = $key - 1;
                                    ?>
                                    <div style="display:none;" class="thumb-sm" data-src="<?php echo $mediumurl ?>" data-id="<?php echo $imgid ?>" data-page="<?php echo (int) (($imgid - 1) / 20) + 1 ?>">
                                        <span class="imgid" itemid="<?php echo $row ?>" ><?php echo $imgid ?></span>
                                        <img src="<?php echo $thumburl ?>" title="<?php echo $row ?>" alt="<?php echo $row ?>" />
                                        <a class="fancybox" rel="group" href="<?php echo $mediumurl ?>"></a>
                                    </div>
                                    <?php
                                }
                            }
                            ?>
                            <div id="pagination"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script type="text/javascript">
        var imgid = document.location.hash;
        $(document).ready(function() {
            if (imgid != '') {
                imgid = parseInt(imgid.replace('#', ''));
                init_gallery_random();
            }
        });
        $('.imgid + img').bind('click', function() {
            imgid = $(this).prev().html();
            document.location.hash = imgid;
            init_gallery_random();
        });
        function init_gallery_random() {
            $('.container .col-7.abcxyz').css('width',($('.container').outerWidth(true)-315-10)+'px');
            $('.share-btn').css('display', '');
            $('.slide-btn').css('display', '');
            $('.cancel-btn').css('display', 'none');
            // $('.select-btn').css('display', 'none');
            $('.actions-inner').css('display', 'none');
            $('.slide_thumb').css('display', 'none');
            $('.slide_detail').css('display', '');
            var options = {
                currentPage: 1,
                totalPages: <?php echo (int) ((count($allthumbs) - 3) / 20) + 1 ?>,
                onPageClicked: function(e, originalEvent, type, page) {
                    $('.thumb-sm').css('display', 'none');
                    $('.thumb-sm[data-page=' + page + ']').css('display', '');
                },
                onPageChanged: function(e, oldPage, newPage) {
                    $('.thumb-sm').css('display', 'none');
                    $('.thumb-sm[data-page=' + newPage + ']').css('display', '');
                }
            }
            $('#pagination').bootstrapPaginator(options);
            $('.thumb-sm[data-id=' + imgid + ']').click();
            var current_page = $('.thumb-sm[data-id=' + imgid + ']').attr('data-page');
            $('#pagination').bootstrapPaginator("show", current_page);
            if (current_page == 1) {
                $('.thumb-sm').css('display', 'none');
                $('.thumb-sm[data-page=1]').css('display', '');
            }
        }
    </script>
    <script type="text/javascript">
        $('.fullimage img').live('click', function() {
            var current_thumb = $('.thumb-sm.active').attr('data-id');
            $('.thumb-sm[data-id=' + (parseInt(current_thumb)) + ']').find('.fancybox').click();
        });
        $('.thumb-sm').live('click', function() {
            var src_image = $(this).attr('data-src');
            $('.fullimage img').attr('src', src_image);
            $('.thumb-sm').removeClass('active');
            $(this).addClass('active');

            var current_thumb = $('.thumb-sm.active').attr('data-id');
            $('.current-image').html(parseInt(current_thumb));
            document.location.hash = current_thumb;
        });
        $('.fancybox-skin a[title=Previous], .next-last.no-left span').live('click', function() {
            var current_thumb = $('.thumb-sm.active').attr('data-id');
            if (current_thumb == 1)
                return;
            $('.thumb-sm').removeClass('active');
            $('.thumb-sm[data-id=' + (parseInt(current_thumb) - 1) + ']').addClass('active');

            var current_page = $('.thumb-sm[data-id=' + current_thumb + ']').attr('data-page');
            var prev_page = $('.thumb-sm[data-id=' + (parseInt(current_thumb) - 1) + ']').attr('data-page');
            if (prev_page != current_page)
                $('#pagination').bootstrapPaginator("show", prev_page);

            $('.current-image').html(parseInt(current_thumb) - 1);
            var src_image = $('.thumb-sm[data-id=' + (parseInt(current_thumb) - 1) + ']').attr('data-src');
            $('.fullimage img').attr('src', src_image);
            document.location.hash = parseInt(current_thumb) - 1;
        });
        $('.fancybox-skin a[title=Next], .next-last.no-right span').live('click', function() {
            var current_thumb = $('.thumb-sm.active').attr('data-id');
            if (current_thumb ==<?php echo (count($allthumbs) - 2); ?>)
                return;
            $('.thumb-sm').removeClass('active');
            $('.thumb-sm[data-id=' + (parseInt(current_thumb) + 1) + ']').addClass('active');

            var current_page = $('.thumb-sm[data-id=' + current_thumb + ']').attr('data-page');
            var next_page = $('.thumb-sm[data-id=' + (parseInt(current_thumb) + 1) + ']').attr('data-page');
            if (next_page != current_page)
                $('#pagination').bootstrapPaginator("show", next_page);

            $('.current-image').html(parseInt(current_thumb) + 1);
            var src_image = $('.thumb-sm[data-id=' + (parseInt(current_thumb) + 1) + ']').attr('data-src');
            $('.fullimage img').attr('src', src_image);
            document.location.hash = parseInt(current_thumb) + 1;
        });

        $('#share-buttons a[href=javascript:;]').live('click',function() {
            window.open($(this).attr('data'), 't', 'toolbar=0,resizable=1,status=0,width=640,height=480');
            return false;
        });
        $(".fancybox").attr('title',' ');
        $(".fancybox").fancybox({
            closeBtn: true,
            beforeShow: function () {
                if (this.title) {
                    this.title += '<div id="share-buttons">\
                    <a href="javascript:;" data="http://www.facebook.com/sharer.php?u=' + this.href + '" target="_blank"><img src="http://www.simplesharebuttons.com/images/somacro/facebook.png" alt="Facebook" /></a>\
                    <a href="javascript:;" data="http://twitter.com/share?url=' + this.href + '&text=' + this.href + '" target="_blank"><img src="http://www.simplesharebuttons.com/images/somacro/twitter.png" alt="Twitter" /></a>\
                    <a href="javascript:;" data="https://plus.google.com/share?url=' + this.href + '" target="_blank"><img src="http://www.simplesharebuttons.com/images/somacro/google.png" alt="Google" /></a>\
                    <a href="javascript:;" data="http://www.digg.com/submit?url=' + this.href + '" target="_blank"><img src="http://www.simplesharebuttons.com/images/somacro/diggit.png" alt="Digg" /></a>\
                    <a href="javascript:;" data="http://reddit.com/submit?url=' + this.href + '&title=' + this.href + '" target="_blank"><img src="http://www.simplesharebuttons.com/images/somacro/reddit.png" alt="Reddit" /></a>\
                    <a href="javascript:;" data="http://www.linkedin.com/shareArticle?mini=true&url=' + this.href + '" target="_blank"><img src="http://www.simplesharebuttons.com/images/somacro/linkedin.png" alt="LinkedIn" /></a>\
                    <a href="javascript:void((function()%7Bvar%20e=document.createElement(\'script\');e.setAttribute(\'type\',\'text/javascript\');e.setAttribute(\'charset\',\'UTF-8\');e.setAttribute(\'src\',\'http://assets.pinterest.com/js/pinmarklet.js?r=\'+Math.random()*99999999);document.body.appendChild(e)%7D)());"><img src="http://www.simplesharebuttons.com/images/somacro/pinterest.png" alt="Pinterest" /></a>\
                    </div>';
                }
            },
            helpers: {
                title: {type: 'inside'},
            }
        });
        $(".fancybox_thumb").attr('title',' ');
        $(".fancybox_thumb").fancybox({
            closeBtn: true,
            beforeShow: function () {
                if (this.title) {
                   this.title += '<div id="share-buttons">\
                    <a href="javascript:;" data="http://www.facebook.com/sharer.php?u=' + this.href + '" target="_blank"><img src="http://www.simplesharebuttons.com/images/somacro/facebook.png" alt="Facebook" /></a>\
                    <a href="javascript:;" data="http://twitter.com/share?url=' + this.href + '&text=' + this.href + '" target="_blank"><img src="http://www.simplesharebuttons.com/images/somacro/twitter.png" alt="Twitter" /></a>\
                    <a href="javascript:;" data="https://plus.google.com/share?url=' + this.href + '" target="_blank"><img src="http://www.simplesharebuttons.com/images/somacro/google.png" alt="Google" /></a>\
                    <a href="javascript:;" data="http://www.digg.com/submit?url=' + this.href + '" target="_blank"><img src="http://www.simplesharebuttons.com/images/somacro/diggit.png" alt="Digg" /></a>\
                    <a href="javascript:;" data="http://reddit.com/submit?url=' + this.href + '&title=' + this.href + '" target="_blank"><img src="http://www.simplesharebuttons.com/images/somacro/reddit.png" alt="Reddit" /></a>\
                    <a href="javascript:;" data="http://www.linkedin.com/shareArticle?mini=true&url=' + this.href + '" target="_blank"><img src="http://www.simplesharebuttons.com/images/somacro/linkedin.png" alt="LinkedIn" /></a>\
                    <a href="javascript:void((function()%7Bvar%20e=document.createElement(\'script\');e.setAttribute(\'type\',\'text/javascript\');e.setAttribute(\'charset\',\'UTF-8\');e.setAttribute(\'src\',\'http://assets.pinterest.com/js/pinmarklet.js?r=\'+Math.random()*99999999);document.body.appendChild(e)%7D)());"><img src="http://www.simplesharebuttons.com/images/somacro/pinterest.png" alt="Pinterest" /></a>\
                    </div>';
                }
            },
            helpers: {
                title: {type: 'inside'},
            }
        });
    </script>
    <div style="display:none;"><input type="text" id="flash" /></div>
    <div id="messagebox">
        <h2 id="messagebox-heading"> Đang lưu hình...</h2>
        <p id="messagebox-description"> Vui lòng chờ trong giây lát</p>
        <span class="icon"></span>
    </div>
    <!-- SLIDE DETAIL -->
</div>
<?php get_footer(); ?>
